import { defineStore } from 'pinia';

const useThemeStore = defineStore({
  id: 'theme',
  state: () => {
    return {
      themeType: 'default',
      themeColor: '#22fffe',
    };
  },
  getters: {
    getThemeType: (state) => state.themeType,
    getThemeColor: (state) => state.themeColor,
  },
  actions: {
    setThemeType(type: string) {
      this.themeType = type || 'default';
      if (type) {
        document.documentElement.setAttribute('theme', type);
        this.themeColor = '#fce09a';
      } else {
        document.documentElement.removeAttribute('theme');
        this.themeColor = '#658d45';
      }
    },
  },
});
export default useThemeStore;
